#include "SqList.h"
#include "LinkedList.h"
void question1(){
    LinkedList list;
    int nums[] = {1, 4, 2, 8};
    createByArray(list, nums, 4);
    printf("\n新建链表如下:");
    printLinkedList(list);

    //查找
    printf("\n----------演示查找----------\n");
    printf("请输入一个待查找的整数:");
    int e;
    scanf("%d", &e);
    int i = findEle(list, e);
    if(i){
        printf("找到 %d 位于第 %d 个节点", e, i);
    }else{
        printf("未找到");
    }

    //删除
    printf("\n----------演示删除----------\n");
    printf("请输入一个待删除的整数:");
    scanf("%d", &e);
    removeEle(list, e);
    printLinkedList(list);
    
    //插入
    printf("\n----------演示插入----------\n");
    int index;
    printf("请输入插入位置:");
    scanf("%d", &index);
    printf("请输入待插入的整数:");
    scanf("%d", &e);
    Status status = insert(list, index, e);
    if(!status){
        printf("插入位置 %d 非法", index);
    }
    printLinkedList(list);
}

void question2(){
    //演示用户输入创建顺序表
    SqList list1, list2;
    int len1, len2;
    printf("请输入第1个顺序表的长度:");
    scanf("%d", &len1);
    printf("请输入第2个顺序表的长度:");
    scanf("%d", &len2);
    
    
    initByUser(list1, list2, len1, len2);
    printf("第一个顺序表：");
    printSqList(list1);

    printf("\n");

    printf("第二个顺序表:");
    printSqList(list2);
    //演示合并
    SqList list;
    mergeTowAscendingList(list1, list2, list);
    printf("\n合并后的顺序表:");
    printSqList(list);
}

int main(){
    question1();
    question2();
    return 0;
}
